package com.springstudy;


import com.springstudy.beans.OtherBean2;
import com.springstudy.config.SpringConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Tamako
 * @since 2025/1/9 15:19
 */
public class ApplicationContextTest {
    public static void main(String[] args) {
        System.setProperty("spring.profiles.active", "dev");

        //xml方式的spring容器
//        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        //注解方式的spring容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
//        UserDao userDao = context.getBean("userDao", UserDao.class);
//        UserService userService = (UserService) context.getBean("userService");
//        userDao.show();
//        userService.show();
//        context.close();
//        Object dataSource = context.getBean("dataSource");
//        System.out.println(dataSource);
//        UserService userService = context.getBean("userService", UserService.class);
//        userService.show();
        Object otherBean2 = context.getBean(OtherBean2.class);
        System.out.println(otherBean2);

    }
}
